<?php

	require_once('config.php');
	//This function connects to the database
	//XXX: this file has been simplified for use with one database server, as opposed to the two originally used by Maptrick.
	//In the original code, connect_db() took one argument that specified which database server should be connected to.
	//In the new design, only one database server should be needed, so the other code should be modified to fit this behaviour.
	
	function connect_db() {
		global $db_host, $db_user, $db_pass, $db_name;
		
		$link = mysql_connect($db_host, $db_user, $db_pass) or die("<FONT COLOR=red SIZE=20>Can't connect to the database! If this problem persists, contact the administrator.</FONT><BR/><BR/>");
		mysql_select_db($db_name, $link) or die("<FONT COLOR=red SIZE=20>Database is not available! Come back later!</FONT><BR/><BR/>");
		mysql_query("SET NAMES utf8",$link) or die (mysql_error());
		return $link;
	}
	
	function error($string) {
		echo $string;
	}
